package ch.fusun.baron.weather;

/**
 * The world representation
 */
public class World {

	private final Cube[][][] cubes;

	/**
	 * @param i
	 *            The width extension
	 * @param j
	 *            The height extension
	 * @param k
	 *            The altitude extension
	 */
	public World(int i, int j, int k) {
		cubes = new Cube[i][j][k];
		for (int x = 0; x < i; x++) {
			for (int y = 0; y < j; y++) {
				for (int z = 0; z < k; z++) {
					cubes[x][y][z] = new Cube(x, y, z);
				}
			}
		}
	}

	/**
	 * Copy Constructor
	 * 
	 * @param world
	 *            world to copy
	 */
	public World(World world) {
		Cube[][][] otherCubes = world.getCubes();
		this.cubes = new Cube[otherCubes.length][otherCubes[0].length][otherCubes[0][0].length];
		for (int i = 0; i < otherCubes.length; i++) {
			for (int j = 0; j < otherCubes[i].length; j++) {
				for (int k = 0; k < otherCubes[i][j].length; k++) {
					this.cubes[i][j][k] = new Cube(otherCubes[i][j][k]);
				}
			}
		}
	}

	/**
	 * @return all cubes
	 */
	public Cube[][][] getCubes() {
		return cubes;
	}

	/**
	 * @param i
	 *            width position
	 * @param j
	 *            height position
	 * @param k
	 *            altitude position
	 * @return The cube at that position
	 */
	public Cube getCube(int i, int j, int k) {
		return cubes[i][j][k];
	}
}
